<?php

/**
 * Description of My_Form_Decorator_FormCancel
 *
 * @author Kam
 */
class My_Form_Decorator_FormCancel extends Zend_Form_Decorator_Abstract {

    public function render($content) {
        $options = $this->getOptions();
        $position = isset($options['position']) ? strtolower($options['position']) : 'right';
        if (empty($position) || !in_array($position, array('left', 'right'))) {
            $position = 'right';
        }
        $url = isset($options['url']) ? $options['url'] : '/';
        $class = isset($options['class']) ? $options['class'] : '';
        $class .= ' form-cancel form-cancel-'.$position;
        $label = isset($options['label']) ? $options['label'] : '';
        if (empty($label)) {
            $label = 'Cancel';
        }
        $html = '<a class="'.$class.'" href="' . $url . '">' . $label . '</a>';
        if ($position == 'left') {
            return $html . $content;
        }
        return $content . $html;
    }

}
